<template>
	<view class="main">
		<code-elf-guide v-if="guidePages"></code-elf-guide>
	</view>
</template>

<script>
	let that
	import {mapGetters,mapActions} from 'vuex'
	import codeElfGuide from '@/components/code-elf-guide/code-elf-guide.vue'
	export default {
        components: {
            codeElfGuide
        },
		computed: {
			...mapGetters(['APPTheme','userInfo','api']),
		},
		data() {
			return {
				guidePages:true,
			}
		},
		onLoad(){
			that=this
			this.loadExecution()
		},
		methods: {
			...mapActions(['set_userInfo','set_userToken']),
			
			loadExecution: function(){
				/**
				 * 获取本地存储中launchFlag的值
				 * 若存在，说明不是首次启动，直接进入首页；
				 * 若不存在，说明是首次启动，进入引导页；
				 */
				try {
					// 获取本地存储中launchFlag标识
				    const value = uni.getStorageSync('launchFlag');
				    if (value) {
						// launchFlag=true直接跳转到首页
						uni.switchTab({
							url: '../../tabbar/index'
						});
				    } else {
						// launchFlag!=true显示引导页
				        this.guidePages = true
				    }
				} catch(e) { 
					// error 
					uni.setStorage({ 
						key: 'launchFlag', 
						data: true, 
						success: function () {
							console.log('error时存储launchFlag');
						} 
					}); 
					this.guidePages = true
				}
				return;
			}
		}
	}
</script>

<style>
	page,.main{
		width: 100%;
		height: 100%;
	}
</style>
